PHLEGM v4 Data-Driven Audit Library Checkpoint - 2026-09-27

- Adds a dedicated generic audit.lib boundary, implemented by lib/audit.bi.
- audit.lib owns CRC32/SHA-1 byte identity, profile parsing, generic validation helpers, and optional exact reference-catalog lookup.
- Firmware CRC32 verification now reuses audit.lib instead of owning a second checksum implementation.
- NES cartridge parsing is driven by cfg/machine/nintendo/NES-NTSC/ines-audit.config.phlegm.
- The profile declares header size/magic, field offsets, masks/shifts, PRG/CHR unit sizes, trainer placement, legacy-header recovery, mapper geometry, hash regions, and anomaly labels.
- machine.config.phlegm chooses the audit profile and the mapper set enabled for that machine. Runtime mapper behavior remains compiled code, while selection and media-format facts remain data.
- The optional sibling ines-reference.config.phlegm catalog uses SHA1|CRC32|status|title|notes records. PHLEGM never infers clean/hack/bad-dump status from a hash mismatch; only an exact catalog record supplies classification.
- Audit definitions live inside the machine directory so normal machine-bundle synchronization carries them without adding a fifth repository category.
- AUDIT is the canonical command. The selected machine chooses its default provider with audit_targets/audit_default_target in machine.config.phlegm. NES routes AUDIT to the inserted cartridge through audit.lib and its configured profile.
- AUDIT reprints resident PRG/CHR identity hashes after state/session restore and, when the original source remains available, recomputes whole-image CRC32/SHA-1, profile-derived flags, and exact reference-catalog status.
- CARTRIDGE AUDIT remains as a compatibility alias only; GUI Memory / Program -> Audit executes AUDIT directly.
- CHR-RAM cartridges are identified explicitly instead of inventing a CHR-ROM hash.
- Legacy contaminated padding, trainer presence, and trailing data remain factual audit flags.
- audit.lib includes CRC32/SHA-1 known-vector self-tests using the ASCII string abc.
- All modified source/config/documentation text uses Windows CRLF line endings.

Static validation performed in this checkpoint:
- Audit profile required-field validation: PASS.
- Legacy DiskDude-style 1942 header emulation: recovers mapper 0 with PRG=2 units and CHR=1 unit.
- Clean Donkey Kong iNES header emulation: resolves mapper 0.
- Function/Sub block-count sanity: PASS for audit.bi, cartridge.bi, firmware.bi, and PHLEGM.bas.
- No single-line conditional ConsolePrint macro invocations remain.
- CRLF-only scan: PASS across 292 source/config/documentation/script text files.
- FreeBASIC compiler is not installed in this execution environment, so a Windows compile/runtime pass is still required through the PHLEGM builder.
